﻿using Prism.Commands;
using Prism.Mvvm;
using Prism.Services.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DingVision.Axis.ViewModels.Dialogs
{
    public class TeachPointDialogViewModel : BindableBase, IDialogAware
    {
        public string Title { get; set; } = "新建点位信息";
        private string pIndex;
        public string PIndex
        {
            get { return pIndex; }
            set { SetProperty(ref pIndex, value); }
        }
        private string pointLabelInput;
        public string PointLabelInput
        {
            get { return pointLabelInput; }
            set { SetProperty(ref pointLabelInput, value); }
        }
        private DelegateCommand oKButtonCommand;
        public DelegateCommand OKButtonCommand =>
            oKButtonCommand ?? (oKButtonCommand = new DelegateCommand(ExecuteOKButtonCommand));
        private DelegateCommand _cancelButtonCommand;
        public DelegateCommand CancelButtonCommand =>
            _cancelButtonCommand ?? (_cancelButtonCommand = new DelegateCommand(ExecuteCancelButtonCommand));

        void ExecuteCancelButtonCommand()
        {
            RequestClose?.Invoke(new DialogResult(ButtonResult.No));
        }
        void ExecuteOKButtonCommand()
        {
            DialogParameters param = new DialogParameters();
            param.Add("PName", PointLabelInput);
            RequestClose?.Invoke(new DialogResult(ButtonResult.OK, param));
        }
        public event Action<IDialogResult> RequestClose;

        public bool CanCloseDialog()
        {
            return true;
        }

        public void OnDialogClosed()
        {
            
        }

        public void OnDialogOpened(IDialogParameters parameters)
        {
            PIndex = parameters.GetValue<string>("PIndex");//参数进来;键值对
        }
    }
}
